﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DB;
using Model;

namespace Control
{
    public class CustomerController
    {
        DbCustomer dbCustomer;
        public CustomerController()
        {
            dbCustomer = new DbCustomer();
        }

        public void CreateCustomer(string name, string address, string phoneNo, string email, string type)
        {
            try
            {
                Customer newCustomer = new Customer(name, address, phoneNo, email, type);

                dbCustomer.InsertCustomer(newCustomer);
            }
            catch (Exception ex)
            {

                Console.WriteLine("Ctrl Caught: " + ex.Message);
            }
        }

        //public void CreateCustomer(string name, string phoneNo)
        //{
        //    try
        //    {
        //        Customer newCustomer = new Customer();
        //        newCustomer.Name = name;
        //        newCustomer.PhoneNo = phoneNo;

        //        dbCustomer.InsertCustomer(newCustomer);
        //    }
        //    catch (Exception ex)
        //    {

        //        Console.WriteLine("Ctrl Caught: " + ex.Message);
        //    }
        //}

        public void DeleteCustomer(string phoneNo)
        {
            Customer newCustomer = new Customer(phoneNo);

            dbCustomer.DeleteCustomer(newCustomer);
        }

        public List<Customer> FindAllCustomers()
        {
            return dbCustomer.FindAllCustomers();
        }

        public Customer FindCustomer(string phoneNo)
        {
            return dbCustomer.FindCustomer(phoneNo);
        }
    }
}
